<?php
namespace models;

class setups
{

//根据IP取当前机房设置
    public function get($room)
    {

        return db("setups")->join('as a
            left join tb_categorys as b on a.category_id = b.id
            left join tb_tasks as c on a.task_id = c.id
            left join tb_classes as d on a.class_id = d.id
            left join tb_users as e on a.teacher_id = e.id')
            ->where('room = ?', $room)
            ->fetch('
            b.name as category_name,
            c.name as task_name,
            c.ext as task_ext,
            d.name as class_name,
            e.id as teacher_id,
            e.name as teacher_username,
            e.realname as realname,
            a.*
            ');
    }

// 删除当前机房的所有设置
    public function del($room)
    {
        return db('setups')->where('room = ?', $room)->delete();
    }

}
